import QtQuick
import QtQuick.Controls

Rectangle {
    width: 400
    height: 300
    color: "lightgray"

    Button {
        text: "右键点击显示菜单"
        anchors.centerIn: parent
        
        MouseArea {
            anchors.fill: parent
            acceptedButtons: Qt.RightButton
            onClicked: contextMenu.popup()
        }
    }

    Menu {
        id: contextMenu
        
        MenuItem {
            text: "复制"
            icon.source: "icons/copy.png"
            onTriggered: console.log("复制被点击")
        }
        MenuItem {
            text: "剪切"
            icon.source: "icons/cut.png"
            onTriggered: console.log("剪切被点击")
        }
        MenuSeparator { }
        MenuItem {
            text: "退出"
            onTriggered: Qt.quit()
        }
    }
}
